﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Classic" xmlns:Microsoft_Windows_Themes1="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Luna" xmlns:Microsoft_Samples_KMoore_WPFSamples_DateControls="clr-namespace:Microsoft.Samples.KMoore.WPFSamples.DateControls;assembly=WPFSamplesLib">
	
	<!-- Resource dictionary entries should be defined here. -->
	<ResourceDictionary.MergedDictionaries>
  		<ResourceDictionary Source="Brushes.xaml" />
		<ResourceDictionary Source="ComboBox.xaml" />
    </ResourceDictionary.MergedDictionaries>
	
	
	<Style x:Key="DatePickerStyle1" TargetType="{x:Type Microsoft_Samples_KMoore_WPFSamples_DateControls:DatePicker}">
		<Setter Property="FocusVisualStyle">
			<Setter.Value>
				<Style>
					<Setter Property="Control.Template">
						<Setter.Value>
							<ControlTemplate>
								<Border>
									<Rectangle Stroke="#FF000000" StrokeDashArray="1 2" StrokeThickness="1" Margin="4,4,21,4"/>
								</Border>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>
			</Setter.Value>
		</Setter>
		<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
		<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
		<Setter Property="BorderBrush" Value="#FF7F9DB9"/>
		<Setter Property="BorderThickness" Value="1,1,1,1"/>
		<Setter Property="Padding" Value="1,1,1,1"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Microsoft_Samples_KMoore_WPFSamples_DateControls:DatePicker}">
					<Grid Width="Auto">
						<Border Background="{TemplateBinding Background}" BorderBrush="{DynamicResource LightBlueFontBrush}" BorderThickness="1,1,1,1" Padding="1,1,1,1">
							<Grid Grid.IsSharedSizeScope="True">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="1"/>
									<ColumnDefinition Width="*"/>
									<ColumnDefinition Width="Auto"/>
								</Grid.ColumnDefinitions>
								<Border Margin="{TemplateBinding Padding}" x:Name="SelectedItemBorder" Grid.ColumnSpan="2"/>
								<TextBlock x:Name="UnEditableSite" VerticalAlignment="Center" Grid.Column="1" Text="{TemplateBinding Text}"/>
								<TextBox Visibility="Collapsed" Margin="{TemplateBinding Padding}" x:Name="PART_EditableTextBox" Grid.Column="1" IsReadOnly="{Binding Path=IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}">
									<TextBox.Style>
										<Style TargetType="{x:Type TextBox}">
											<Setter Property="OverridesDefaultStyle" Value="True"/>
											<Setter Property="AllowDrop" Value="True"/>
											<Setter Property="Background" Value="#00FFFFFF"/>
											<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
											<Setter Property="MinWidth" Value="0"/>
											<Setter Property="MinHeight" Value="0"/>
											<Setter Property="Width" Value="Auto"/>
											<Setter Property="Height" Value="Auto"/>
											<Setter Property="Template">
												<Setter.Value>
													<ControlTemplate TargetType="{x:Type TextBox}">
														<ScrollViewer Focusable="False" x:Name="PART_ContentHost" Background="{TemplateBinding Background}" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden"/>
													</ControlTemplate>
												</Setter.Value>
											</Setter>
										</Style>
									</TextBox.Style>
								</TextBox>
								<ToggleButton Focusable="False" x:Name="FakeDropDownButton" Grid.ColumnSpan="2" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
									<ToggleButton.Style>
										<Style TargetType="{x:Type ToggleButton}">
											<Setter Property="Background" Value="#00FFFFFF"/>
											<Setter Property="Template">
												<Setter.Value>
													<ControlTemplate TargetType="{x:Type ToggleButton}">
														<Border Background="{TemplateBinding Background}"/>
													</ControlTemplate>
												</Setter.Value>
											</Setter>
										</Style>
									</ToggleButton.Style>
								</ToggleButton>
								<Border Grid.Column="2">
									<ToggleButton Style="{StaticResource ComboBoxTransparentButtonStyle}" Grid.ColumnSpan="3" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
									<!--<ToggleButton x:Name="PART_DropDownButton" Background="#FF90D8E1" IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}">
										<Viewbox Width="10" Height="10">
											<Path Fill="#FF000000" Data="M0,0 L4.5,4 9,0 5.5,0 4.5,1 3.5,0 z"/>
										</Viewbox>
									</ToggleButton>-->
								</Border>
							</Grid>
						</Border>
						<Popup Focusable="False" AllowsTransparency="True" IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" Placement="Bottom" x:Name="PART_Popup">
							<Border x:Name="DropDownBorder" Background="{TemplateBinding Background}" BorderThickness="1,0,1,1" BorderBrush="{DynamicResource LightBlueFontBrush}">
								<Microsoft_Samples_KMoore_WPFSamples_DateControls:MonthCalendar x:Name="PART_DatePickerCalendar" Style="{TemplateBinding MonthCalendarStyle}" MaxDate="{TemplateBinding MaxDate}" MaxSelectionCount="1" MinDate="{TemplateBinding MinDate}"/>
							</Border>
						</Popup>
					</Grid>
					<ControlTemplate.Triggers>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsKeyboardFocusWithin" Value="True"/>
								<Condition Property="IsDropDownOpen" Value="False"/>
								<Condition Property="CanEdit" Value="False"/>
							</MultiTrigger.Conditions>
							<Setter Property="Background" TargetName="SelectedItemBorder" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
						</MultiTrigger>
						<Trigger Property="CanEdit" Value="True">
							<Setter Property="Background" TargetName="FakeDropDownButton" Value="{x:Null}"/>
							<Setter Property="Visibility" TargetName="SelectedItemBorder" Value="Collapsed"/>
							<Setter Property="Visibility" TargetName="UnEditableSite" Value="Collapsed"/>
							<Setter Property="Visibility" TargetName="PART_EditableTextBox" Value="Visible"/>
						</Trigger>
						<MultiTrigger>
							<MultiTrigger.Conditions>
								<Condition Property="IsKeyboardFocusWithin" Value="True"/>
								<Condition Property="IsDropDownOpen" Value="False"/>
								<Condition Property="CanEdit" Value="False"/>
							</MultiTrigger.Conditions>
							<Setter Property="Foreground" TargetName="UnEditableSite" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
						</MultiTrigger>
						<Trigger Property="IsEnabled" Value="False">
							<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
							<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
						</Trigger>
						<Trigger Property="Width" Value="Auto">
							<Setter Property="MinWidth" Value="150"/>
						</Trigger>
						<Trigger Property="Height" Value="Auto">
							<Setter Property="MinHeight" Value="20"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
</ResourceDictionary>